<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>门店管理页</title>
		<link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<style>
			select{
				width: 150px;
				color: #666;
				height: 38px;
			    line-height: 1.3;
			    border:1px solid #e6e6e6;
			    background-color: #fff;
			    border-radius: 2px;
			    padding-left: 5px;
			}
		</style>
	</head>

	<body onload="storeSearch()"> 
		<div class="weadmin-nav">
			<span class="layui-breadcrumb" style="visibility: visible">
		        <a href="">数据管理</a>
		        <a>
	          		<cite>数据列表</cite>
		        </a>
	      	</span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i>
			</a>
		</div>
		<div class="wrap">
			<blockquote class="layui-elem-quote news_search">
				<div class="layui-inline"  >
				
					<select id="pageId" name="pageId" onchange="storeSearch()" >  
					  <option value="workbench"id="workbench" name="workbench" lay-filter="workbench"  >工作台访问量</option>
					  <option value="recruit"id="recruit" name="recruit" lay-filter="recruit"  >招募客户访问量</option>
					  <option value="contact"id="contact" name="contact" lay-filter="contact"  >客户通讯录访问量</option>
					  <option value="search"id="search" name="search" lay-filter="search"  >搜索访问量</option>
					</select> 
					
				  <div class="layui-inline"   >  
				  <input type="text" placeholder="开始日期" class="layui-input" id="startTime">
				</div>
				
				<div class="layui-inline"   >  
				  <input type="text" placeholder="结束日期"  class="layui-input" id="endTime">
				</div>	 
										
					<button class="layui-btn search_btn" onclick="storeSearch()" >查询</button>
				 
				</div>
			</blockquote>
			<!--  数据列表表格 -->
			<table class="layui-table" lay-filter="store_table" id="store_table" style="margin: 0"></table>
		</div>
		<script src="../../publicjs/jquery-1.8.0.min.js"></script>
		<script src="../../lib/layui/layui.js"></script>
		<script src="../../static/js/admin.js" charset="utf-8"></script>
		<script src="../../publicjs/smallkingutil.js"></script>
		<script src="../../publicjs/area.js"></script>
		<script src="../../publicjs/select.js"></script>
		<script src="../../lib/echarts/echarts.min.js"></script>
		<script src="../../lib/echarts/echarts.js"></script>
	<!-- 开始时间 -->
	<script id="startTime" >
		layui.use('laydate', function(){
		  var laydate = layui.laydate;	  
		  //执行一个laydate实例
		  laydate.render({
			//type: 'datetime',
		    elem: '#startTime',  
		    format:'yyyy-MM-dd',
		    value: new Date(new Date()-1000*60*60*24*7),
		    max: 'new Date(new Date()+1000*60*60*24*7)'
		  });
		});
	</script>
	 <!-- 结束时间 -->
	 <script id="endTime">
		layui.use('laydate', function(){
		  var laydate = layui.laydate;		
		  //执行一个laydate实例
		  laydate.render({
			//type: 'datetime',
		    elem: '#endTime',
		    format:'yyyy-MM-dd',
		    value: new Date(),
		    max: 'new Date()'
		  });
		});
	</script>
	
	<div id="main" style="width: 1300px;height:600px;"></div>	
	<script type="text/javascript" >
		// 搜索按钮
		
		window.storeSearch = function(res){
			console.info("开始");
		    var pageId = $('#pageId option:selected').val();
			var startTime = $('#startTime').val();
			var endTime = $('#endTime').val() ; 
		
			 console.info(startTime);
			 console.info(endTime);
			
 			 if(startTime =="undefined" || startTime == null || startTime == ""){
				startTime = new Date(new Date()-1000*60*60*24*7).toLocaleString();
			} 
			 if(endTime =="undefined" || endTime == null || endTime == ""){
				 endTime = new Date();
				 endTime =endTime.getFullYear()+'-'+(endTime.getMonth()+1)+'-'+endTime.getDate()+' '+endTime.getHours()+':'
				 		  +endTime.getMinutes()+':'+endTime.getSeconds()+':'+endTime.getMilliseconds() 
			} 
			console.info(startTime);
		    console.info(endTime);
		    
	        $.ajax({ 
	        	type : "post",
	            async : false,          
	            url : commonUtil.domain() +'/admin/wxwork/tracking/query',    
	            data : {
	            	pageId: pageId,  
	            	startTime: startTime,
	            	endTime: endTime
	            },
	            dataType : "json",        //返回数据形式为json
	            success : function(res) {
                 	// 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('main'));
                    // 指定图表的配置项和数据
                    var option = {
                        title: {
                            text: '小程序运行数据展示'
                        },
                        tooltip: {},
                        legend: {
                            data:['点击次数']
                        },
                        xAxis: {
                            data: res.data.xList
                        },
                        yAxis: {},
                        series: [{
                        	type: 'bar',
                            data: res.data.yList,
                            type: 'line',
                            smooth: true
                        }]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
	           },
	            error : function(errorMsg) {
	                //请求失败时执行该函数
	            alert("请求数据失败!");
	            myChart.hideLoading(); 
	            }           
	       })	
		}
	</script>

	</body>
</html>